package main

import "fmt"

func main() {

	fmt.Println(fibonacci(6))
	fmt.Println(remove("abeclvo", "hello")) //elo O(n)  O(1)
}

func fibonacci(index int) int {
	if index == 1 || index == 2 {
		return 1
	}

	a, b := 1, 1
	for i := 3; i < index; i++ {
		a, b = b, (a + b)
		fmt.Println(a, b)
	}
	return a + b
}

//查找两个字符串中相同字符，并且去掉重复
func remove(str1, str2 string) string {

	var tmp [256]int
	var result []byte

	for _, v := range str1 {
		tmp[v] = 1
	}

	for k, v2 := range str2 {
		if tmp[v2] == 1 {
			tmp[v2] = 0 //去重
			result = append(result, str2[k])
		}
	}

	return string(result)
}
